<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>组件属性-props</title>

  <!-- 引入react核心库 -->
  <script src="../js/react.development.js"></script>
  <!-- 引入react-dom，用于支持react操作dom -->
  <script src="../js/react-dom.development.js"></script>
  <!-- 引入babel，用于将jsx转为js -->
  <script src="../js/babel.min.js"></script>

  <style>
    .title {
      background-color: pink;
    }
  </style>
</head>

<body>
  <!-- 准备容器 -->
  <div id="test"></div>


  <script type="text/babel">
    // 1. 创建类式组件
    class MyComponent extends React.Component {

      render() {
        return (
          <ul>
            <li>姓名：{this.props.name}</li>
            <li>性别：{this.props.sex}</li>
            <li>年龄：{this.props.age}</li>
          </ul>
        )
      }

    }

    let p = { name: 'zs', sex: '男', age: '28' }
    // 2. 渲染组件到页面
    // ReactDOM.render(<MyComponent name="zs" sex="男" age="19" />, document.getElementById('test'))

    // 展开运算符批量传递props
    ReactDOM.render(<MyComponent {...p} />, document.getElementById('test'))


  </script>
</body>

</html>